package sq.service.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import sq.dao.Food;
import sq.dao.Orders;
import sq.dao.User;
import sq.repository.UserRepository;
import sq.service.UserService;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 *
 * @Author: sunquan
 * @Date: 2018/5/8
 * @Time: 12:41
 */
@Service
public class UserServiceImpl implements UserService {
    @Autowired
    private UserRepository userRepository;
    @Override
    public List<User> findAllUsers() {
        List<User> userList = userRepository.findAll();
        return userList;
    }

    @Override
    public List<User> findSearchUser(String userInfo, String userInfo1) {
        List<User> user=null;
        user= userRepository.findUserByUsernameLikeOrPhoneOrderByUserId("%"+userInfo1+"%",userInfo1);
        return user;
    }

    @Override
    public User findUser(Integer userId) {

        return userRepository.findUserByUserId(userId);
    }

    @Override
    public void updateUser(Integer userId, String username, String password) {
        userRepository.updateUserByUserId(userId,username,password);
    }

    @Override
    public void deleteUser(Integer userId) {
        userRepository.delete(userId);
    }
}
